package com.zapi.lottery.controller;

import com.zapi.lottery.entity.LotteryRecord;
import com.zapi.lottery.service.LotteryRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * LotteryRecord 控制器
 * 提供抽奖记录的增删改查接口
 * @author: zhonglz
 * @DATE: 2024-06-09
 */
@RestController
@RequestMapping("/lottery/record")
public class LotteryRecordController {
    @Autowired
    private LotteryRecordService lotteryRecordService;

    /**
     * 新增或更新抽奖记录
     */
    @PostMapping
    public boolean save(@RequestBody LotteryRecord lotteryRecord) {
        return lotteryRecordService.saveOrUpdate(lotteryRecord);
    }

    /**
     * 删除抽奖记录
     */
    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id) {
        return lotteryRecordService.removeById(id);
    }

    /**
     * 根据ID获取抽奖记录
     */
    @GetMapping("/{id}")
    public LotteryRecord getById(@PathVariable Integer id) {
        return lotteryRecordService.getById(id);
    }

    /**
     * 获取所有抽奖记录列表
     */
    @GetMapping
    public List<LotteryRecord> findAll() {
        return lotteryRecordService.list();
    }
} 